'''
作者：小鹿
个人网站：https://www.siena.zone
创作日期：2020年5月
'''
from PyQt5.QtWidgets import *
import Files.Img_04_WaterMark as funcWM
import sys, cv2, os
import numpy as np
from PyQt5.QtGui import *
from PyQt5.Qt import *
from PyQt5.QtCore import *

global watermark_info
watermark_info = [None, None, 1, 0.5, 0.45]

global save_path
save_path = []

class Watermark_Main_UI(QWidget):

    Signal = pyqtSignal(list)
    Signal_img_list = pyqtSignal(list)

    def __init__(self):
        super(Watermark_Main_UI, self).__init__()

        self.setWindowTitle('水印选项')

        self.imgs = []
        self.file_total_amount = 0

        self.watermark_imgFrame()
        self.watermark_Options()
        self.watermark_LayoutSetup()

        self.thread = ImageDemo()
        self.thread.Image2show_as_array.connect(self.ShowDemo)

    def watermark_imgFrame(self):

        self.setFixedSize(1000, 700)

        self.imgFrame = QVBoxLayout()
        self.imgFrame_asWidget = QWidget()

        self.imgFrameImgLayout = QHBoxLayout()
        self.imgFrameImgLayout.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.imgFrameImg = QLabel()
        self.imgFrameImg.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.imgFrameImg.setFixedSize(500, 500)
        self.imgFrameImg.setStyleSheet("background:#3F3F3F;")
        self.imgFrameImg.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.imgFrameImgLayout.addWidget(self.imgFrameImg)

        self.imgFrameInfoLayout = QHBoxLayout()
        self.imgFrameInfoLayout.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.imgFrameInfoLayout_asWidget = QWidget()
        self.imgFrameInfo = QLineEdit()
        self.imgFrameInfo.setText('待处理图片')
        self.imgFrameInfo.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.imgFrameInfo.setEnabled(False)
        self.imgFrameInfoLayout.addWidget(self.imgFrameInfo)

        self.imgFrame.addLayout(self.imgFrameImgLayout)
        self.imgFrame.addLayout(self.imgFrameInfoLayout)
        self.imgFrame.addWidget(QWidget())
        self.imgFrame_asWidget.setLayout(self.imgFrame)

    def watermark_Options(self):

        self.path_redirected = './Images/Splash.png'

        self.Options = QVBoxLayout()
        self.Options.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.Options_asWidget = QWidget()
        self.Options_asWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.Options_asWidget.setFixedWidth(400)

        self.watermarkBtnLayout = QHBoxLayout()
        self.watermarkBtnLayout.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.BaseImage = QPushButton('添加图片')
        self.BaseImage.clicked.connect(self.open_image)
        self.BaseImage.setFixedSize(100, 32)
        self.BaseImage.setEnabled(True)
        self.watermarkBtnLayout.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.watermarkBtn = QPushButton('添加水印')
        self.watermarkBtn.clicked.connect(self.open_watermark)
        self.watermarkBtn.setFixedSize(100, 32)
        self.watermarkBtn.setEnabled(False)
        self.watermarkPos = QComboBox()
        self.watermarkPos.setEnabled(False)
        self.watermarkPos.setFixedSize(100, 32)
        self.watermarkPos.addItem('左上角')
        self.watermarkPos.addItem('正上方')
        self.watermarkPos.addItem('右上角')
        self.watermarkPos.addItem('左侧中间')
        self.watermarkPos.addItem('正中心')
        self.watermarkPos.addItem('右侧中间')
        self.watermarkPos.addItem('左下角')
        self.watermarkPos.addItem('正下方')
        self.watermarkPos.addItem('右下角')
        self.watermarkPos.setStyleSheet('QComboBox::down-arrow{border-image:url(%s/Images/Btn_dropdown.png);}' % self.path_redirected)
        self.watermarkPos.currentIndexChanged.connect(self.watermarkPosition)
        self.watermarkBtnLayout.addWidget(self.BaseImage)
        self.watermarkBtnLayout.addWidget(self.watermarkBtn)
        self.watermarkBtnLayout.addWidget(self.watermarkPos)

        self.watermarkPathLayout = QHBoxLayout()
        self.watermarkPathLayout.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.watermarkPath = QTextEdit('请添加需要加水印的图片')
        self.watermarkPath.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.watermarkPath.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.watermarkPath.setStyleSheet(
            "background:#505050;color:#FFFFFF;border:0px;padding-top:12px;border-radius:4px;")
        self.watermarkPath.setFixedSize(360, 48)
        self.watermarkPath.setEnabled(False)
        self.watermarkPathLayout.addWidget(self.watermarkPath)

        self.watermarkADJ_Opacity = QHBoxLayout()
        self.watermarkADJ_Opacity.setSpacing(0)
        self.watermarkADJ_Opacity_value_show = QLineEdit()
        self.watermarkADJ_Opacity_value_show.setText('不透明度：50 %')
        self.watermarkADJ_Opacity_value_show.setEnabled(False)
        self.watermarkADJ_Opacity_value_show.setFixedWidth(120)
        self.watermarkADJ_Opacity_value_show.setAlignment(Qt.AlignLeft)
        self.watermarkADJ_Opacity_value = QSlider(Qt.Horizontal)
        self.watermarkADJ_Opacity_value.setFixedSize(150, 20)
        self.watermarkADJ_Opacity_value.setMinimum(0)
        self.watermarkADJ_Opacity_value.setMaximum(100)
        self.watermarkADJ_Opacity_value.setValue(50)
        self.watermarkADJ_Opacity_value.setEnabled(False)
        self.watermarkADJ_Opacity_value.valueChanged.connect(self.watermarkOpacity)
        '''self.watermarkADJ_Opacity_value.valueChanged.connect(self.MarkOpacityValue)'''
        self.watermarkADJ_Opacity.addWidget(self.watermarkADJ_Opacity_value_show)
        self.watermarkADJ_Opacity.addWidget(self.watermarkADJ_Opacity_value)

        self.watermarkADJ_Scale = QHBoxLayout()
        self.watermarkADJ_Scale.setSpacing(0)
        self.watermarkADJ_Scale_value_show = QLineEdit()
        self.watermarkADJ_Scale_value_show.setText('占图片比例：45 %')
        self.watermarkADJ_Scale_value_show.setEnabled(False)
        self.watermarkADJ_Scale_value_show.setFixedWidth(120)
        self.watermarkADJ_Scale_value_show.setAlignment(Qt.AlignLeft)
        self.watermarkADJ_Scale_value = QSlider(Qt.Horizontal)
        self.watermarkADJ_Scale_value.setFixedSize(150, 20)
        self.watermarkADJ_Scale_value.setMinimum(0)
        self.watermarkADJ_Scale_value.setMaximum(90)
        self.watermarkADJ_Scale_value.setValue(45)
        self.watermarkADJ_Scale_value.setEnabled(False)
        self.watermarkADJ_Scale_value.valueChanged.connect(self.watermarkScale)
        '''self.watermarkADJ_Scale_value.valueChanged.connect(self.MarkScaleValue)'''
        self.watermarkADJ_Scale.addWidget(self.watermarkADJ_Scale_value_show)
        self.watermarkADJ_Scale.addWidget(self.watermarkADJ_Scale_value)

        self.watermarkConfirmCancelLayout = QHBoxLayout()
        self.watermarkConfirmCancelLayout.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.watermarkClear = QPushButton('重置')
        self.watermarkClear.clicked.connect(self.OptClear)
        self.watermarkClear.setFixedSize(80, 32)
        self.watermarkClear.setEnabled(False)
        self.watermarkConfirm = QPushButton('确定')
        self.watermarkConfirm.clicked.connect(self.OptConfirm)
        self.watermarkConfirm.setFixedSize(80, 32)
        self.watermarkConfirm.setEnabled(False)
        self.watermarkCancel = QPushButton('取消')
        self.watermarkCancel.clicked.connect(self.OptCancel)
        self.watermarkCancel.setFixedSize(80, 32)
        self.watermarkConfirmCancelLayout.addWidget(self.watermarkClear)
        self.watermarkConfirmCancelLayout.addWidget(self.watermarkConfirm)
        self.watermarkConfirmCancelLayout.addWidget(self.watermarkCancel)

        self.fileList = QHBoxLayout()
        self.fileList_widget = QTableWidget()
        self.fileList_widget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        self.fileList_widget.setMinimumHeight(250)
        '''self.fileList_widget.setFixedWidth(294)'''
        self.fileList_widget.horizontalHeader().setSectionResizeMode(QHeaderView.Custom)
        self.fileList_widget.horizontalHeader().setVisible(True)
        self.fileList_widget.verticalHeader().setSectionResizeMode(QHeaderView.Interactive)
        self.fileList_widget.verticalHeader().setVisible(False)
        self.fileList_widget.setRowCount(5)
        self.fileList_widget.setColumnCount(2)
        self.fileList_widget.setHorizontalHeaderLabels(['图片名称 ', '状态 '])
        self.fileList_widget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.fileList_widget.setColumnWidth(0, 300)
        self.fileList_widget.setColumnWidth(1, 50)
        self.file_name = QTableWidgetItem()
        self.file_name.setText('文件名')
        self.file_status = QTableWidgetItem()
        self.file_status.setText('状态')
        for l in range(self.fileList_widget.rowCount()):
            self.fileList_widget.setRowHeight(l, 25)
        self.fileList_widget.setShowGrid(False)
        self.fileList_widget.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.fileList_widget.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.fileList_widget.setSelectionMode(QAbstractItemView.SingleSelection)
        self.fileList_widget.setEnabled(False)
        self.fileList_widget.itemClicked.connect(self.FileListActivated)
        '''self.fileList_widget.horizontalHeader().setSectionResizeMode(0, QHeaderView.Interactive)'''
        self.fileList.addWidget(self.fileList_widget)

        self.fileList_info = QHBoxLayout()
        self.fileList_info_widget = QLineEdit()
        self.fileList_info_widget.setText('没有待处理图片')
        self.fileList_info_widget.setEnabled(False)
        self.fileList_info_widget.setFixedWidth(120)
        self.fileList_info_widget.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.fileList_info_widget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        self.fileList_info_widget.setStyleSheet(
            "background:transparent;color:#FFFFFF;border:0px;padding-top:12px;border-radius:4px;")
        self.fileList_info_widget.setFixedSize(360, 24)
        self.fileList_info_widget.setEnabled(False)
        self.fileList_info.addWidget(self.fileList_info_widget)

        self.Options.addWidget(QWidget())
        self.Options.addLayout(self.watermarkPathLayout)
        self.Options.addWidget(QWidget())
        self.Options.addLayout(self.watermarkBtnLayout)
        self.Options.addWidget(QWidget())
        self.Options.addLayout(self.watermarkADJ_Opacity)
        self.Options.addLayout(self.watermarkADJ_Scale)
        self.Options.addLayout(self.fileList_info)
        self.Options.addWidget(QWidget())
        self.Options.addLayout(self.fileList)
        self.Options.addWidget(QWidget())
        self.Options.addLayout(self.watermarkConfirmCancelLayout)
        self.Options.addWidget(QWidget())

        self.Options_asWidget.setLayout(self.Options)

    def watermark_LayoutSetup(self):

        self.splitter = QSplitter()

        self.LayoutAll = QHBoxLayout()
        self.LayoutAll.addWidget(self.imgFrame_asWidget)
        self.LayoutAll.addWidget(self.Options_asWidget)

        self.setLayout(self.LayoutAll)

    def progress_AddImage(self):

        self.img_pb = QProgressDialog()
        self.img_pb.setFixedSize(300, 100)
        self.img_pb.setCancelButtonText('取消')
        self.img_pb.setAutoReset(True)
        self.img_pb.setAutoClose(True)
        self.img_pb.setStyleSheet('''
        QPushButton{background:#3D3D3D;color: #FFFFFF;font-family:;padding-left:10px;padding-right:10px;border-radius:4px;border:1px solid #9E9E9E;}
        QPushButton:disabled{background:#555555;color:#EEEEEE;}
        QPushButton:pressed{border:1px solid #EEEEEE;}
        QLineEdit:disabled{background:transparent;border:0px;color:#FFFFFF;}
        QLabel:disabled{color:#FFFFFF;}
        ''')
        self.img_pb_palette = QPalette()
        self.img_pb_palette.setColor(QPalette.Background, QColor(74, 74, 74))
        self.img_pb.setPalette(self.img_pb_palette)


    ############ 以下为槽函数 ############

    ###### 主线程槽函数 ######

    def open_image(self):
        self.update()
        self.img_info = QFileDialog.getOpenFileNames(self, "选择图片", "/" , "JPEG(*.jpg *.jpeg);;PNG(*.png);;TIFF(*.tiff);;BMP(*.bmp)")
        self.imgs = self.img_info[0]
        imgs = self.imgs
        print(imgs)
        self.watermarkClear.setEnabled(True)

        '''这个地方可以写个线程'''
        #填表操作开始条件
        if len(self.imgs) > 0:
            watermark_info[0] = self.imgs[0]
            print(watermark_info)
            self.BaseImage.setEnabled(False)
            self.update()
            for l in range(len(self.imgs)):
                if len(self.imgs) > 5:
                    self.fileList_widget.setRowCount(len(self.imgs))
                    self.file_total_amount = self.fileList_widget.rowCount()
                else:
                    self.fileList_widget.setRowCount(5)
                    self.file_total_amount = len(self.imgs)
                save_path.append(self.imgs[l])
                #定义列表项
                img_name_item = QTableWidgetItem()
                img_name_item.setText(str(self.imgs[l]))
                img_status = QTableWidgetItem()
                img_status.setText('未处理')
                self.fileList_widget.setRowHeight(l, 25)
                #填写列表项
                self.fileList_widget.setItem(l, 0, img_name_item)
                self.fileList_widget.setItem(l, 1, img_status)
                self.imgToScale = QPixmap(watermark_info[0])
                #添加图片按钮文字改变
                self.BaseImage.setText('图片已添加')
                #请添加水印提示
                self.watermarkPath.setText('请添加黑底白色水印')
                self.watermarkPath.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
                #文件队列信息文字改变
                self.fileList_info_widget.setText('待处理图片：%d张' % self.file_total_amount)
                #文件队列调整。包括显示模式居中调整。l代表文件数（也就是文件名个数），这样也就代表了队列行数，因为一行一个文件名。还包括是否激活
                self.fileList_widget.setEnabled(True)
                #填入图片
                if self.imgToScale.width() > self.imgToScale.height():
                    self.rate = self.imgToScale.width() / self.imgToScale.height()
                    self.DemoScaled = self.imgToScale.scaled(475, int(475 / self.rate), Qt.KeepAspectRatio,
                                                                Qt.SmoothTransformation)
                else:
                    self.rate = self.imgToScale.height() / self.imgToScale.width()
                    self.DemoScaled = self.imgToScale.scaled(int(475 / self.rate), 475, Qt.KeepAspectRatio,
                                                                Qt.SmoothTransformation)
                self.imgFrameImg.setPixmap(self.DemoScaled)
                #设定控件可用性
                self.watermarkBtn.setEnabled(True)
                '''self.img_box_af.set_image(self.img_bf_to_browse)'''
                self.update()
            for i in range(self.file_total_amount):
                self.fileList_widget.setRowHeight(i, 25)
                self.fileList_widget.item(i, 0).setTextAlignment(Qt.AlignCenter | Qt.AlignVCenter)
                self.fileList_widget.item(i, 1).setTextAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        else:
            self.update()

    def open_watermark(self):
        self.watermarkInfo = QFileDialog.getOpenFileName(self, "选择图片", "/", "JPEG(*.jpg *.jpeg);;TIFF(*.tiff);;BMP(*.bmp)")
        _, self.wm_name = os.path.split(self.watermarkInfo[0])

        #加载水印操作开始条件
        if len(self.imgs) > 0:
            watermark_info[1] = self.watermarkInfo[0]
            print(watermark_info[1])
            self.update()
            if len(self.wm_name) != 0:
                self.watermarkPath.setText('水印名称：' + str(self.wm_name))
                self.watermarkPath.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
                self.watermarkConfirm.setEnabled(True)
                self.watermarkPos.setEnabled(True)
                self.watermarkADJ_Opacity_value.setEnabled(True)
                self.watermarkADJ_Scale_value.setEnabled(True)
                self.watermarkBtn.setEnabled(False)
                self.watermarkBtn.setText('水印已添加')
                self.imgFrameInfo.setText('效果预览')
                self.fileList_info_widget.setText('待处理图片：%d张；' % self.file_total_amount + '调整后，点击列表刷新预览')
                self.fileList_widget.setEnabled(True)
            else:
                self.watermarkPath.setText('请添加黑底白色水印')
                self.watermarkPath.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
                self.watermarkConfirm.setEnabled(False)
                self.watermarkPos.setEnabled(False)
                self.watermarkADJ_Opacity_value.setEnabled(False)
                self.watermarkADJ_Scale_value.setEnabled(False)
        else:
            self.watermarkPath.setText('请添加需要加水印的图片')
            self.watermarkPath.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
            self.watermarkConfirm.setEnabled(False)
            self.watermarkPos.setEnabled(False)
            self.watermarkADJ_Opacity_value.setEnabled(False)
            self.watermarkADJ_Scale_value.setEnabled(False)

    def watermarkPosition(self, value):

        watermark_info[2] = value + 1
        print(watermark_info[2])


    def watermarkOpacity(self, value):

        self.watermarkADJ_Opacity_value_show.setText('不透明度：%d' %  + value + ' %')
        self.WM_Opacity = value / 100
        watermark_info[3] = self.WM_Opacity

        print(self.WM_Opacity)

    def watermarkScale(self, value):

        self.watermarkADJ_Scale_value_show.setText('占图片比例：%d' % + value + ' %')
        self.WM_Scale = value / 100
        watermark_info[4] = self.WM_Scale

        print(self.WM_Scale)

    def FileListActivated(self):
        self.selected_imgs = len(self.fileList_widget.selectedRanges())
        #print('共选中%s张图片' % self.selected_imgs)

        '''这个地方可以写个线程'''

        self.row = self.fileList_widget.selectedItems()[0].row()
        self.img_br = self.row
        self.text = self.fileList_widget.selectedItems()[0].text()
        self.img_bf_to_browse = self.text
        watermark_info[0] = self.img_bf_to_browse
        if watermark_info[1] != None:
            self.thread.img_data(watermark_info)
            self.thread.start()
        else:
            self.imgToScale = QPixmap(self.img_bf_to_browse)
            if self.imgToScale.width() > self.imgToScale.height():
                self.rate = int(self.imgToScale.width() / self.imgToScale.height())
                self.DemoScaled = self.imgToScale.scaled(self.rate * 475, 475, Qt.KeepAspectRatio,
                                                         Qt.SmoothTransformation)
            else:
                self.rate = int(self.imgToScale.height() / self.imgToScale.width())
                self.DemoScaled = self.imgToScale.scaled(475, 475 * self.rate, Qt.KeepAspectRatio,
                                                         Qt.SmoothTransformation)
        self.imgFrameImg.setPixmap(self.DemoScaled)

        #print(self.row)
        #print(self.text)

    def OptClear(self):

        self.watermarkPath.setText('水印名称：无')
        self.watermarkPath.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        self.BaseImage.setEnabled(True)
        self.BaseImage.setText('添加图片')
        self.watermarkBtn.setEnabled(False)
        self.watermarkBtn.setText('添加水印')
        self.watermarkPos.setEnabled(False)
        self.fileList_widget.clearContents()
        self.fileList_widget.setEnabled(False)
        self.fileList_info_widget.setText('没有待处理图片')
        self.watermarkADJ_Opacity_value.setEnabled(False)
        self.watermarkADJ_Scale_value.setEnabled(False)
        self.imgFrameImg.clear()
        self.imgFrameInfo.setText('待处理图片')
        self.watermarkConfirm.setEnabled(False)
        self.watermarkClear.setEnabled(False)

        watermark_info = [None, None, 1, 0.5, 0.45]
        save_path.clear()

    def OptConfirm(self):
        '''self.thread = ThreadBrowse()
        self.thread.Img2see.connect(self.ImagePreview)
        self.thread.start()
        self.thread.exec()'''

        self.Signal.emit(watermark_info)
        self.Signal_img_list.emit(save_path)
        self.close()

    def OptCancel(self):

        self.close()

    ###### 子线程槽函数 ######

    def ShowDemo(self, array):

        self.imgQt = QImage(array.data, array.shape[1], array.shape[0],
                            QImage.Format_BGR888)
        self.imgToScale = QPixmap.fromImage(self.imgQt)

        if self.imgToScale.width() > self.imgToScale.height():
            self.rate = int(self.imgToScale.width() / self.imgToScale.height())
            self.DemoScaled = self.imgToScale.scaled(self.rate * 475, 475, Qt.KeepAspectRatio,
                                                     Qt.SmoothTransformation)
        else:
            self.rate = int(self.imgToScale.height() / self.imgToScale.width())
            self.DemoScaled = self.imgToScale.scaled(475, 475 * self.rate, Qt.KeepAspectRatio,
                                                     Qt.SmoothTransformation)
        self.imgFrameImg.setPixmap(self.DemoScaled)


class ImageDemo(QThread):

    Image2show_as_array = pyqtSignal(np.ndarray)

    def __init__(self):
        super(ImageDemo, self).__init__()

    def img_data(self, watermarkInfo):
        self.info = watermarkInfo

    def run(self):
        if self.info[0] != None and self.info[1] != None:
            self.imgShow_cv = funcWM.WaterMark().watermark(self.info[0], self.info[1], self.info[2], self.info[3],
                                                           self.info[4])
            # self.imgShow_cv_rgb = cv2.cvtColor(self.imgShow_cv, cv2.COLOR_RGB2BGR)
            # cv2.imwrite(self.demo_show_path, self.imgShow_cv)

            if self.imgShow_cv.shape[1] % 4 != 0:
                self.rate = self.imgShow_cv.shape[0] / self.imgShow_cv.shape[1]
                self.new_width = int(self.imgShow_cv.shape[1] - (self.imgShow_cv.shape[1] % 4))
                self.new_height = int(self.imgShow_cv.shape[1] * self.rate)
                self.imgShow_cv_resized = cv2.resize(self.imgShow_cv, (self.new_width, self.new_height))
            else:
                self.imgShow_cv_resized = self.imgShow_cv

            self.data = np.array(self.imgShow_cv_resized)
            self.Image2show_as_array.emit(self.data)
        self.exit(0)

if __name__ == '__main__':

    app = QApplication(sys.argv)
    qssStyle = '''
        QPushButton{
            background:#3D3D3D;
            color: #FFFFFF;
            font-family:;
            padding-left:10px;
            padding-right:10px;
            border-radius:4px;
            border:1px solid #9E9E9E;
        }
        QPushButton:disabled{
            background:#555555;
            color:#EEEEEE;
        }
        QPushButton:pressed{
            border:1px solid #EEEEEE;
        }
        QLineEdit:disabled{
            background:transparent;
            border:0px;
            color:#FFFFFF;
        }
        QLabel:disabled{
            color:#FFFFFF;
        }
        QSlider::handle{
            width:6px;
            margin:-4px;
            padding-left:3px;
            padding-right:3px;
            background-color:#FFFFFF;
            border-radius:2px;
        }
        QSlider::groove:horizontal{
            height: 4px;
            padding-left:10px;
            padding-right:10px;
            background: #FFFFFF;
            border-radius:2px;
        }
        QSlider::sub-page:horizontal{
            height: 4px;
            background: qlineargradient(x1:0, x2:1, stop:0 #C5FFA1, stop:1 #69F6B7);
            border-radius:2px;
        }
        QSlider::add-page:horizontal{
            height: 4px;
            background: #808080;
            border: 0px solid #777;
            border-radius:2px;
        }
        QComboBox{
            background:#3D3D3D;
            color:#FFFFFF;
            border-radius:4px;
        }
        QComboBox::drop-down{
            background:#3D3D3D;
            color:#FFFFFF;
            border-radius:4px;
            border:0px;
            width:32px;
        }
        QComboBox:hover{
            background:#3D3D3D;
            color:#FFFFFF;
            border-radius:4px;
            border:0px;
        }
        QComboBox:hover:checked{
            background:#3D3D3D;
            color:#FFFFFF;
            border-radius:4px;
            border:0px;
        }
        QComboBox:off{
            background:#3D3D3D;
            color:#FFFFFF;
            border-radius:4px;
            border:0px;
        }
        QComboBox:disabled{
            background:#555555;
            color:#EEEEEE;
        }
        QRadioButton{
            margin-left:4px;
            padding-right:4px;
            color:#FFFFFF;
        }
        QTabWidget::tab-bar{border-width:0px;align-center;}
        QTabBar::tab{
            background: #3D3D3D;
            color:#FFFFFF;
            margin:0px;
            padding-left:12px;
            padding-right:12px;
            padding-top:4px;
            padding-bottom:4px;
        }
        QTabBar::tab:selected{
            background: qlineargradient(x1:0, x2:1, stop:0 #C5FFA1, stop:1 #69F6B7);
            color:#000000;
            margin:0px;
            border-radius:4px;
            padding-left:12px;
            padding-right:12px;
            padding-top:8px;
            padding-bottom:8px;
        }
        QHeaderView{
            background:#808080;
            color:#FFFFFF;
            padding-left:4px;
            border:0px;
        }
        QHeaderView::section{
            background:#808080;
            color:#FFFFFF;
            border:0px;
        }
        QTableWidget{
            background:#3D3D3D;
            color:#FFFFFF;
            border:0px;
            border-radius:4px;
        }
        QTableWidget::item{
            border:0px;
        }
        QTableWidget::item::selected{
            background:#FFFFFF;
            color:#000000;
            border:0px;
        }
    '''
    app.setStyleSheet(qssStyle)
    app.setFont(QFont("Source Han Sans SC"))
    box = Watermark_Main_UI()
    palette = QPalette()
    palette.setColor(QPalette.Background, QColor(74, 74, 74))
    box.setPalette(palette)
    box.show()
    sys.exit(app.exec_())